#!/usr/bin/env python
# -*-coding:utf-8-*-
# File    : liyuqi.py
# Date    : 2021-01-23
# Author  : Tom.Lee

#使用标准库操作
count = 0
height = 0
names = []
age = 0

with open("students.csv") as fs:
    data_lines = fs.readlines()[1:]
    for line in data_lines:
        stdinfo = line.split(',')
        height += int(stdinfo[3])
        name = stdinfo[0]
        age += int(stdinfo[2])
        count += 1
        if int(stdinfo[2]) >10:
            names.append(name)

print("学生的平均身高为：{}".format(height/count))
print("学生的平均年龄为：{}".format(int(age/count)))
print("年龄大于10岁学生有：{}".format("，".join(names)))





#使用pandas
import pandas as pd

df = pd.read_csv("students.csv", encoding="gbk")
print(df["身高（cm）"].mean())
print(df["年龄"].mean())
print(df[(df["年龄"] > 10)]["姓名"])
